#ifndef PHONEDEVICE_H
#define PHONEDEVICE_H

#include <QTimer>
#include <QDateTime>
#include <QElapsedTimer>

#include "Device/BaseDevice.h"
#include "Protocol/CloudProtocol.h"
#include "System/System.h"

#include "DataType/CurrentPointStore.h"

#include "Command/CloudProtocol/AppSearchCmd.h"
#include "Command/CloudProtocol/AppSearchResponseCmd.h"
#include "Command/CloudProtocol/ResponseCmd.h"
#include "Command/CloudProtocol/HandshakeCmd.h"
#include "Command/CloudProtocol/HandshakeSucceedCmd.h"
#include "Command/CloudProtocol/HeartbeatCmd.h"
#include "Command/CloudProtocol/UserLoginCmd.h"
#include "Command/CloudProtocol/UesrLoginSucceedCmd.h"
#include "Command/CloudProtocol/CloudControlPointCmd.h"
#include "Command/CloudProtocol/UpdatePointCmd.h"
#include "Command/CloudProtocol/DownloadPointListCmd.h"
#include "Command/CloudProtocol/DownloadPointListRequestCmd.h"
#include "Command/CloudProtocol/CustomSceneControlCmd.h"
#include"Command/CloudProtocol/HeartBestcmd.h"
#include"Command/ZigbeeProtocol/SetNewZigbeeNetCmd.h"
#include "Command/ZigbeeProtocol/Zigbee3NewJoinParamCmd.h"
#include"Command/ZigbeeProtocol/Zigbee3ControlPointListCmd.h"
#include "Command/ZigbeeProtocol/Zigbee3QueryBackCmd.h"
#include"Command/CloudProtocol/PhoneToSetZB3cmd.h"
#include"Command/CloudProtocol/PhoneToSetInfraredCmd.h"
#include"Command/CloudProtocol/PhoneToAllocationCmd.h"
#include"Command/CloudProtocol/QueryOtherEquipmentCmd.h"

#include "Function/ControlPointFunc.h"
#include "Function/UpdatePointFunc.h"
#include"Function/LogicCloudDataFunc.h"


#include "File/Xml/MacXml.h"
#include "File/Xml/UserListXml.h"
#include "File/Xml/CustomSceneXml.h"
#include "File/Xml/Zigbee3ListXml.h"
#include"File/Xml/Zigbee3InfraredXml.h"
#include "File/Xml/SavePointXml.h"
#include"File/Xml/OtherEquipmentXml.h"

class PhoneDevice : public BaseInterface<PhoneDevice>
{
    Q_OBJECT
public:
    Q_INVOKABLE explicit PhoneDevice(QObject *parent = 0);
    void appSearchCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
private:

    CloudProtocol *cloudProtocol;

    QList<PortStruct> clientList;

     QMultiMap<int, Package> m_WaitBackMap;

    bool isLegalClient(PortStruct source);
   // void appSearchCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    void handshakeCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    void heartBeatCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    void userLoginCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    void controlPointCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    void downloadPointListRequestCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    void customSceneControlCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
    void updatePointCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);

    void updatePointFuncHandle(QSharedPointer<BaseFunc> sharedFunc);
    void LogicCloudDataFuncHandle(QSharedPointer<BaseFunc> sharedFunc);

    void SetUPZigbee3CmdHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
    void AllowToJoinZigbee3CmdHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
    void ApplyToQuitZigbee3CmdHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
   // void ZBQuitFeedBackCmdHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
    void QueryZigbee3PropertiesCmdHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
    void QueryOtherEquipmentHandle(PortStruct target,QSharedPointer<BaseCmd> sharedCmd);
    void SetZigbee3DataCmdHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
    void Zigbee3QueryDataCmdHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
    void ZB3OPInfraredToLearnHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
    void ZB3OPInfraredToTestHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
    void ZB3OPInfraredToSaveHandle(PortStruct target, QSharedPointer<BaseCmd> sharedCmd);
    void phoneToallocationCmdHandle(PortStruct source,QSharedPointer<BaseCmd> sharedCmd);
public slots:
    void clientDisconnectedSlot(PortStruct source);


};

#endif // PHONEDEVICE_H
